<!DOCTYPE html>
<html class="pixel-ratio-3 retina android android-5 android-5-1-1">
<head>
    <title>医生注册</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="">

    <link rel="stylesheet" href="../../lib/weui.min.css">
    <link rel="stylesheet" href="../../css/jquery-weui.css">
    <link rel="stylesheet" href="../../css/home.css">
    <link rel="stylesheet" href="../../plugins/fontaw/css/font-awesome.css">
<style>
    .sms-disabled{
        color: gray;
    }
</style>
</head>
<body ontouchstart>
<div class="weui-flex">
    <div class="weui-flex__item">
        <div class="home-header" >
            <h2>医 生 注 册</h2>
        </div>
    </div>
</div>
<div class="weui-cells weui-cells_form">
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">姓 名</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="text"  name="docName">
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">手机号</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" placeholder="请输入手机号" id="phone" name="phone">
        </div>
    </div>
    <div class="weui-cell weui-cell_vcode">
        <div class="weui-cell__hd">
            <label class="weui-label">验证码</label>
        </div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="text" name="smsCode" >
        </div>
        <div class="weui-cell__ft">
            <button class="weui-vcode-btn">获取验证码</button>
        </div>
    </div>
</div>

<div class="weui-btn-area">
    <a class="weui-btn weui-btn_primary rega" href="javascript:" > 注 册 </a>
</div>


<script src="/lib/jquery-2.1.4.js"></script>
<script src="/lib/jquery.form.js"></script>
<script src="/lib/fastclick.js"></script>
<script src="/js/jquery-weui.js"></script>
<script src="/js/home.js"></script>
<script>
   $(function(){
       var wechatName = getQueryString("wechatName");
       var wid = getQueryString("wid");
       if(wechatName){
           $("input[name='docName']").val(wechatName);
       }

       $(".weui-vcode-btn").click(function(){
           var phone  = $("#phone").val();
           if($.trim(phone)!=""){
               $.ajax({
                   url:"/d/doctor/regSMS",
                   data:{"phone":phone},
                   success:function(da){
                       if(da.code=="10000"){
                           var dead  = 60;
                           $(".weui-vcode-btn").attr("disabled",true);
                           $(".weui-vcode-btn").addClass("sms-disabled");
                           $(".weui-vcode-btn").text(dead+"秒后重发");
                           setInterval(function(){
                               if(dead<=0){
                                   $(".weui-vcode-btn").removeClass("sms-disabled");
                                   $(".weui-vcode-btn").attr("disabled",false).text("重新发送");
                               }else{
                                   $(".weui-vcode-btn").text(dead+"秒后重发");
                                   dead--;
                               }
                           },1000);
                       }
                   }
               });
           }
       });

       $(".rega").click(function(){
           var phone  = $("#phone").val();
           var smsCode = $("input[name='smsCode']").val();
           var docName = $("input[name='docName']").val();
           $.ajax({
               url:"/d/doctor/doctorRegist",
               type:"post",
               data:{"phone":phone,"smsCode":smsCode,"docName":docName,"wid":wid},
               beforeSend:function(){
                   enableOrDisableBtn($(".rega"),false,"注 册");
               },
               success:function(da){
                    if(da.code == "10000"){
                        $.toast("注册成功");
                        location.href=da.data;
                    }else{
                        $.toast(da.msg, "forbidden");
                        enableOrDisableBtn($(".rega"),true,"注 册");
                    }
               }
           });
       });
   })
</script>
</body>
</html>